package com.snu.liwei.lyl_api.controller;

import com.snu.liwei.lyl_api.entity.User;
import com.snu.liwei.lyl_api.service.MyInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin(origins ={"http://192.168.31.215:3000","http://127.0.0.1:3000"} )
//@CrossOrigin(origins ="http://192.168.2.103:3000" )
@RequestMapping("hello")
public class HelloController {
    @Autowired
    MyInfoService myInfoService;

    @RequestMapping("SpringSecurity")
    public String SpringSecurity()
    {
        return "Spring Security";
    }

    @RequestMapping("getAll")
    public List<Map<String,Object>> getAll()
    {
        return myInfoService.getAll();
    }

    @RequestMapping("logined")
    public User userLogined(){return new User();}

    @RequestMapping("errInfo")
    public Map<String,Object> notLogin(){
        Map<String,Object> errInfo=new HashMap<>();
        errInfo.put("errCode",1);//1未登录
        return errInfo;
    }
}
